#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.53)
AC_INIT(Qastrocam-g2, 3.6, thx8411@users.sourceforge.net)
AC_CONFIG_HEADER(config.h)

AC_CHECK_PROGS(CXX, g++ g++-4.0 g++-3.3 g++-2.95)
AC_CHECK_PROGS(CC, gcc gcc-4.0 gcc-3.3 gcc-2.95)


AC_LANG(C++)

AC_CANONICAL_HOST

#sinclude(gwqt.m4)

AC_CONFIG_SRCDIR([qastrolib/QCam.cpp])

AC_SUBST(ARCHTYPE)

case "$host" in
   i686-*)
     ARCHTYPE=ia32      
     ;;
   i586-*)
     ARCHTYPE=ia32      
     ;;
   i486-*)
     ARCHTYPE=ia32      
     ;;
   x86_64-*)
     ARCHTYPE=x86_64
     ;;
   *)
     AC_MSG_ERROR("don't know how to handle host type $host")
     ;;
esac

#QT
AC_SUBST(MOC)
AC_SUBST(QT_INC_DIR)
AC_SUBST(QT_LIB_DIR)
AC_SUBST(QT_LIBS)

CXXFLAGS="$CXXFLAGS -I $QT_INC_DIR"
CFLAGS="$CFLAGS -I $QT_INC_DIR"
AC_CHECK_HEADERS(qobject.h)

test -n "$MOC" || MOC=MOC_var_not_set
test -n "$QT_INC_DIR" || QT_INC_DIR=QT_INC_DIR_var_not_set
test -n "$QT_LIB_DIR" || QT_LIB_DIR=QT_LIB_DIR_var_not_set
test -n "$QT_LIBS" || QT_LIBS=QT_LIBS_var_not_set

#cfitsio
AC_SUBST(CFITSIO_LINK)
AC_SUBST(CFITSIO_INC)
test -n "$CFITSIO_INC" || CFITSIO_INC=QT_LIB_DIR_var_not_set
test -n "$CFITSIO_LINK" || CFITSIO_LINK=QT_LIB_DIR_var_not_set

CXXFLAGS="$CXXFLAGS $CFITSIO_INC"
CFLAGS="$CFLAGS $CFITSIO_INC"
AC_CHECK_HEADERS(fitsio.h)

#SDL present? (optional)
AC_PATH_PROG(SDLCONFIG, sdl-config, no)
if test "$SDLCONFIG" != no
then
   CXXFLAGS="$CXXFLAGS "`sdl-config --cflags`
   CFLAGS="$CFLAGS "`sdl-config --cflags`
   CPPFLAGS="$CPPFLAGS "`sdl-config --cflags`
   #LDFLAGS="$LDFLAGS -Wl,-Bstatic -lSDL -Wl,-Bdynamic "`sdl-config --static-libs | sed s/-lSDL//`
   LDFLAGS="$LDFLAGS "`sdl-config --static-libs`
fi

# libavifile present? (optional)
AC_PATH_PROG(AVICONFIG, avifile-config no)
if test "$AVICONFIG" != no
then
   CXXFLAGS="$CXXFLAGS "`$AVICONFIG --cflags`
   CPPFLAGS="$CPPFLAGS "`$AVICONFIG --cflags`
   LDFLAGS="$LDFLAGS "`$AVICONFIG --libs`
fi
AC_CHECK_HEADERS(avifile.h)


AC_CHECK_HEADERS(SDL.h)
#AC_CHECK_LIB(pthread,pthread_create)
#AC_CHECK_LIB(SDL,SDL_InitSubSystem)


	
#AC_CONFIG_FILES([Makefile.common])
AC_OUTPUT(Makefile.vars)
